import * as api from '../../utils/api'
import axios from '../../utils/http'
const state = {
    totalSize: 1,
    tableData: [],
    dialogTableVisible: false,
    bulkData: {
        event_title: '',
        activity_time_start: '',
        activity_time_end: '',
        activity_properties: '',
        join_member_fee: '',
        total_circulation: '',
        number_of_initial_entries: '',
        activity_img: '',
        offer_details: '',
        scope_of_application: '',
        validity_period: '',
        how_to_use: '',
        pledge: '',
        recommended_reason: '',
    },
    bulkState: '1', //模态框状态
    bulkTitle: '', //模态框标题
    AuditVisible: false,
    checkData: []
}
const actions = {
    checkDataA(obj, data) {
        console.log(data);
        obj.commit('checkDataM', data)
    },
    changeImgActions(obj, imgurl) {
        obj.commit('changeImgMutations', imgurl)
    },
    //form表单
    changeDialogActions({ commit }) {
        commit('changeDialogMutations');
    },
    changeDialogActions1({ commit }) {
        commit('changeDialogMutations1');
    },

    //通过审核
    changeAuditDialogActions({ commit }) {
        commit('changeAuditDialogMutations');
    },
    changeAuditDialogActions1({ commit }) {
        commit('changeAuditDialogMutations1');
    },
    changebulkDataActions(obj, bulkdata) {
        obj.commit('changebulkDataMutations', bulkdata)
    },
    changeBulkStateActions(obj, bulkstate) {
        obj.commit('changeBulkStateMutations', bulkstate)
    },
    changebulkTitleActions(obj, title) {
        obj.commit('changebulkTitleMutations', title)
    },

    //分页查询接口
    gettableDataActions(obj, data) {
        console.log(data);
        if (state.bulkState === '1') {
            axios({
                url: api.gbuyqueryGroupPurchaseDiscount,
                method: 'post',
                data: {
                    currentPage: data.nowPage,
                    pageSize: data.perPageNum,
                    active_status: data.active_state,
                    real_estate_name: data.real_estate_id,
                }
            }).then(data => {
                if (data.status === 200) {
                    console.log(data);
                    obj.commit('gettableDataMutations', data)
                }
            }).catch(err => {
                console.log(err);
            })

        }
        if (state.bulkState === '2') {
            axios({
                url: api.ltbqueryLimitedTimeBuying,
                method: 'post',
                data: {
                    currentPage: data.nowPage,
                    pageSize: data.perPageNum,
                    active_status: data.active_state,
                    real_estate_name: data.real_estate_id,

                }
            }).then(data => {
                if (data.status === 200) {
                    obj.commit('gettableDataMutations', data)
                }
            }).catch(err => {
                console.log(err);
            })
        }
        if (state.bulkState === '3') {
            axios({
                url: api.hpsqueryHousePurchaseSubsidy,
                method: 'post',
                data: {
                    currentPage: data.nowPage,
                    pageSize: data.perPageNum,
                    active_status: data.active_state,
                    real_estate_name: data.real_estate_id,

                }
            }).then(data => {
                console.log(data);
                if (data.status === 200) {
                    obj.commit('gettableDataMutations', data)
                }
            }).catch(err => {
                console.log(err);
            })
        }


    }


}

const mutations = {
    checkDataM(state, data) {
        state.checkData = data
    },
    changeImgMutations(state, imgurl) {
        state.bulkData.activity_img = imgurl
    },

    changebulkDataMutations(state, bulkdata) {
        state.bulkData = bulkdata
    },
    changeDialogMutations(state) {
        state.dialogTableVisible = true
    },
    changeDialogMutations1(state) {
        state.dialogTableVisible = false
    },
    changeAuditDialogMutations(state) {
        state.AuditVisible = true
    },
    changeAuditDialogMutations1(state) {
        state.AuditVisible = false
    },
    changeBulkStateMutations(state, bulkstate) {
        state.bulkState = bulkstate
    },
    changebulkTitleMutations(state, title) {
        state.bulkTitle = title
    },
    gettableDataMutations(state, data) {
        state.tableData = data.data.data.dataList
        state.totalSize = data.data.data.totalSize
    }
    // selectcolorMutations(state, color) {
    //     state.currentcolor = color
    //     console.log(color);
    // },
    // changedataMutations(state) {
    //     state.tableData = [{
    //             order_no: '1234567',
    //             chargeback_no: '7654321',
    //             event_title: '蓝光coco',
    //             user_id: 'weishanxing',
    //             order_total: '5000000',
    //             application_time: '2020-10-29'
    //         },
    //         {
    //             order_no: '1234567',
    //             chargeback_no: '7654321',
    //             event_title: '蓝光coco',
    //             user_id: 'weishanxing',
    //             order_total: '5000000',
    //             application_time: '2020-10-29'
    //         },
    //     ]
    // }

}

const getters = {}


export default {
    state,
    actions,
    mutations,
    getters
}